<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
?>
<meta http-equiv="refresh" content="60">
<?
$_SESSION["sessdata"]["pagefrom"]=$_SERVER["QUERY_STRING"];

?>

<!-- Begin Body -->

<style>
.maintitle
	{
	    font-size: 12pt;
		border-bottom: 1px solid #aaa;
		padding: 5px;
		background-color: #efefef;
	}
</style>

<p class="maintitle"><b>BigDaddy</b><br>
<span style="font-size: 10pt;">Server and Application Monitoring Service - visit <A href="http://bigdaddymonitor.org">http://bigdaddymonitor.org</a> for help and manuals</span>

<p class="maintitle"><b>Server Groups</b></p>

<?
$aFailingServerGroups = $BigDaddyData->GetFailingServerGroups();

if (!is_array($aFailingServerGroups))

{
?>
    <p><b>Server Groups:</b></p>
	<ul><li>All services reporting nominal behaviour</li></ul>

<?
}
else
{
?>

    <div class="orgbar"><span class="text"><b>Server Groups With Problems:</b><span></div>
    <table border="0" cellpadding="0" cellspacing="0" width="97%">

<?
	foreach ($aFailingServerGroups as $nIndex => $row)
	{
        $BigDaddyDisplay->ShowServerGroupLine($row);
    }
?>
</table>
<?
}
?>

<p class="maintitle"><b>Servers</b></p>

<?

$aFailingModules = $BigDaddyData->GetFailingServerModules();

if (!is_array($aFailingModules))

{
?>
    <p><b>Monitoring Modules:</b></p>
	<ul><li>All services reporting nominal behaviour</li></ul>

<?
}
else
{
?>

    <div class="orgbar"><span class="text"><b>Monitoring Modules With Problems:</b><span></div>
    <table border="0" cellpadding="0" cellspacing="0" width="97%">

<?
	foreach ($aFailingModules as $nIndex => $row)
	{
        $BigDaddyDisplay->ShowServerModuleLine($row, $row["serverID"]);
    }
?>
</table>
<?
}

$aFailingServers = $BigDaddyData->GetFailingServers();

if (!is_array($aFailingServers))
{
?>
	<p><b>Server Monitoring:</b></p>
	<ul><li>Monitoring is reporting fine on all servers.</li></ul>
<?
}
else
{
?>

	<br />
	<div class="orgbar"><span class="text"><b>Server Monitoring Not Reporting:</b><span></div>
	<table border="0" cellpadding="0" cellspacing="0" width="97%">
	<?
	foreach ($aFailingServers as $nIndex => $row)
	{
         $BigDaddyDisplay->ShowServerLine($row);
	}

?>

</table>

<?
}
?>

<p class="maintitle"><b>Scheduled (Cron) Applications</b></p>

<?

$aFailingCrons = $BigDaddyData->GetFailingCrons();

if (!is_array($aFailingCrons))
{
?>
	<ul><li>All scheduled/applications performing nominally</li></ul>
<?
}
else
{
	?>
	<div class="orgbar"><span class="text"><b>Following Crons/Applications Have Problems</b><span></div>
	<table border="0" cellpadding="0" cellspacing="0" width="97%">
	<?

	foreach ($aFailingCrons as $nIndex => $row)
	{
        $BigDaddyDisplay->ShowCronLine($row);
	}
}
?>

</table>
<p class="maintitle"><b>BigDaddy Monitoring</b></p>

<table border="0" cellpadding="2" cellspacing="0">
<?
function num_minutes($num)
{
    if ($num<120)
	{
		return $num." seconds";
	}
	elseif ($num<6400)
	{
		$seconds=$num%60;
		return floor($num/60).":".$seconds." minutes";
	}
	else
	{
		$minutes=$num%3600;
		return floor($num/3600).":".$minutes." hours";
	}
}

$currentTime=time();

$aReport = $BigDaddyData->GetMonitoringLastReportInfo();

$reportArray=array(
"servermon" => array("Server Monitoring - /bigdaddy/server_monitor"),
"excheck" => array("External Checker - /bigdaddy/external_checker"),
"crontabmon" => array("Crontab Monitor - /bigdaddy/crontab_monitor"),
"servergroupmon" => array("Server Group Monitor - /bigdaddy/servergroup_monitor"),
);
if (is_array($aReport))
{
    foreach ($aReport as $nIndex => $row)
    {
    ?>
        <tr>
            <td><?=$reportArray[$row["ID"]][0];?></td>
            <td>:: Last Reported: <b><?=num_minutes($currentTime-$row["report"]);?></b></td>
            <td>:: Last Reported: <?=get_time_str($row["report"], 2);?></td>
            <td>:: Process: <?=$row["processID"];?></td>
        </tr>
    <?
    }
}
?>
</table>

<p>BigDaddy Version <?=BIGDADDY_VERSION;?>. For more information visit: <a href="http://wwww.bigdaddymonitor.org">http://www.bigdaddymonitor.org</a>. BigDaddy &copy; 2002-2007 BioWare Corp. Licensed under BSD License</p>
